<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script>
        function addEmp(){
            $.ajax({
                type:'get',
                url:'http://localhost:8080/myweb/addEmp',
                data:{
                    name: $('#name').val(),
                    phone: $('#phone').val(),
                    address: $('#address').val()
                },
                dataType: 'json',
                success: function(result){
                    console.log(result)
                    if(result.status === 200){
                        location.href = 'listEmp.html'
                    }else{
                        alert('添加失败：' + result.msg)
                    }
                }
            })
        }
    </script>
</head>
<body>
    <div>
        <h2>添加员工</h2>
        姓名：<input type="text" id="name"> <br>
        电话：<input type="text" id="phone"> <br>
        地址：<input type="text" id="address"> <br>
        <button type="button" onclick="addEmp()">添加</button>
    </div>
</body>
</html>